//
//  Animation.m
//  111
//
//  Created by wuxushun on 16/2/22.
//  Copyright © 2016年 wuxushun. All rights reserved.
//

#import "Animation.h"

//全局静态变量
static block _AddressSelectorBlock;

@implementation Animation

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

+ (CAKeyframeAnimation *)AnimationWithTime:(CGFloat)time withPath:(CGMutablePathRef)path withCompleted:(block)completed{

    _AddressSelectorBlock = [completed copy];
    CAKeyframeAnimation *basic = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    basic.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    basic.delegate = self;
    [basic setPath:path];
    [basic setDuration:time];
    [basic setAutoreverses:NO];
    basic.repeatCount = 1;
    CFRelease(path);
    return basic;

}

+ (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{

    _AddressSelectorBlock();

}

@end
